package com.example.yuejianapp14.Activity.Activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yuejianapp14.Activity.JavaBean.Act;
import com.example.yuejianapp14.Activity.JavaBean.Coach;
import com.example.yuejianapp14.Activity.Listener.ClubNoListListener;
import com.example.yuejianapp14.Activity.Model.ActivityModel;
import com.example.yuejianapp14.Activity.Model.CoachModel;
import com.example.yuejianapp14.R;
import com.squareup.picasso.Picasso;

public class CoachActivity extends AppCompatActivity {
    private TextView Coachinfo;
    private ImageView Coachpic;
    private Button Coachclass,Coachask;
    private Context mContext;
    private String class_id;
    private Button coachcalss,coachask;
    private String coachid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coach);
        initViews();
        getData();
        coachclass();
        coachask();
        Intent intent=getIntent();
        coachid = intent.getStringExtra("coachid");
        Picasso.with(mContext).load("http://10.0.2.2/YueJian/Public/photo/coachphoto/"+getIntent().getStringExtra("coachpic")).into(Coachpic);

    }
    public void initViews(){
        Coachinfo = (TextView) findViewById(R.id.Coachinfo);
        Coachpic=(ImageView)findViewById(R.id.Coachpic);
        coachcalss=(Button) findViewById(R.id.Coachclass);
        coachask=(Button)findViewById(R.id.Coachask);
    }

    ClubNoListListener<Coach> clubNoListListener =new ClubNoListListener<Coach>() {
        @Override
        public void onResponse(Coach coach) {
            Coachinfo.setText(coach.getCoachinstruction());
        }

        @Override
        public void onFail(String msg) {

        }
    };

    private void getData() {
        Intent intent = getIntent();
        CoachModel coachModel =new CoachModel();
        coachModel.coachinfo(intent.getStringExtra("coachid"),clubNoListListener);
    }



   private void coachclass(){
       coachcalss.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               Intent intent = new Intent(CoachActivity.this,Video1Activity.class);
               startActivity(intent);
           }
       });
   }

    private void coachask(){
        coachask.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(CoachActivity.this,CoachAskActivity.class);
                intent.putExtra("coachid",coachid);
                startActivity(intent);
            }
        });
    }


}
